/*
用户登陆的路由组件
*/
import React, {Component} from 'react'
import {NavBar,
    WingBlank,
    List,
    InputItem,
    WhiteSpace,
    Radio,
    Button,
    Icon,} from 'antd-mobile'
import Logo from "../../components/logo/Logo";



export default class Login extends Component {
    state = {
        username: '',  // 用户名
        password: '',  // 密码

    }
    // 处理输入数据的改变: 更新对应的状态
    handleChange=(name,val)=>{
        this.setState({
            [name]:val  // 属性名不是name, 而是name变量的值
        })
    }
    toRegister=()=>{
        this.props.history.replace('/register')
    }
    render () {
        return (
            <div>
                <NavBar>硅&nbsp;谷&nbsp;直&nbsp;聘</NavBar>
                <Logo/>
                <WingBlank>
                    <List>

                        <WhiteSpace/>
                        <InputItem placeholder='请输入用户名' onChange={val => {this.handleChange('username', val)}}>用户名:</InputItem>
                        <WhiteSpace/>
                        <InputItem placeholder='请输入密码' type="password" onChange={val => {this.handleChange('password', val)}}>密&nbsp;&nbsp;&nbsp;码:</InputItem>
                        <WhiteSpace/>

                        <Button type='primary' onClick={this.login}>登&nbsp;&nbsp;&nbsp;陆</Button>
                        <WhiteSpace/>
                        <Button onClick={this.toRegister}>还没有账户</Button>
                    </List>
                </WingBlank>
            </div>
        )
    }
}